#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

const int N = 10005;
int n, g, k, sum;

struct Stu
{
    string email;
    int score;
    bool operator>(const Stu &s) const
    {
        if (this->score != s.score)
        {
            return this->score > s.score;
        }
        return this->email < s.email;
    }
} stus[N];

int main()
{
    cin >> n >> g >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> stus[i].email >> stus[i].score;
        if (stus[i].score >= 60)
        {
            if (stus[i].score >= g)
            {
                sum += 50;
            }
            else
            {
                sum += 20;
            }
        }
    }
    cout << sum << endl;
    int pos = 0;
    sort(stus, stus + n, greater<Stu>());
    for (int i = 1; i <= k; i++)
    {
        int cnt = 0;
        cout << i << " " << stus[pos].email << " " << stus[pos].score << endl;
        while (stus[pos].score == stus[pos + 1].score)
        {
            pos++;
            cnt++;
            cout << i << " " << stus[pos].email << " " << stus[pos].score << endl;
        }
        i += cnt;
        pos++;
    }
    return 0;
}